package com.tianquan.common.instance;

import java.util.Objects;

/**
 *@Author: tianquan
 *@date: 2024-11-03  10:40
 *@Description: 服务实例
 */

public class ServiceInstance {
    private String id;

    private String serverName;

    private String host;

    private int port;

    private int weight;

    public ServiceInstance() {
    }

    public ServiceInstance(String id, String serverName, String host, int port, int weight) {
        this.id = id;
        this.serverName = serverName;
        this.host = host;
        this.port = port;
        this.weight = weight;
    }

    public ServiceInstance(String serverName, String id,int weight) {
        this.serverName = serverName;
        this.id = id;
        this.weight = weight;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ServiceInstance that = (ServiceInstance) o;
        return port == that.port && Objects.equals(id, that.id) && Objects.equals(serverName, that.serverName) && Objects.equals(host, that.host);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, serverName, host, port);
    }

    @Override
    public String toString() {
        return "ServiceInstance{" +
                "id='" + id + '\'' +
                ", serverName='" + serverName + '\'' +
                ", host='" + host + '\'' +
                ", port=" + port +
                '}';
    }

}
